package com.cci.kangdao.controller;

import com.cci.kangdao.service.CertificateService;
import com.cci.kangdao.utilTool.ParameterTool;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 *
 * @author Eric
 *
 */
@Controller
public class CertificateController {

	private Logger log = Logger.getLogger(this.getClass().getName());

	@Autowired
	private CertificateService service;

	/**
	 * 获取技师列表接口
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping("/getTechnicianList.aspx")
	public ModelAndView getTechnicianList(HttpServletRequest request, HttpServletResponse response) {
		try{
			Map<String, Object> map = ParameterTool.getParameterRequest(request, true);
			map.put("response", response);
			map.put("request", request);
			return service.getTechnicianList(map);
		}catch(Exception ex) {
			log.error(ex.getMessage(), ex);
			ParameterTool.writeErrorResponse(response);
		}

		return null;
	}

	/**
	 * 获取技师认证信息接口
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping("/getTechCertCourses.aspx")
	public ModelAndView getTechCertCourses(HttpServletRequest request, HttpServletResponse response) {
		try{
			Map<String, Object> map = ParameterTool.getParameterRequest(request, true);
			map.put("response", response);
			map.put("request", request);
			return service.getTechCertCourses(map);
		}catch(Exception ex) {
			log.error(ex.getMessage(), ex);
			ParameterTool.writeErrorResponse(response);
		}

		return null;
	}

	/**
	 * 上传技师认证信息接口
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping("/uploadTechCertCourses.aspx")
	public ModelAndView uploadTechCertCourses(HttpServletRequest request, HttpServletResponse response) {
		try{
			Map<String, Object> map = ParameterTool.getParameterRequest(request, true);
			map.put("response", response);
			map.put("request", request);
			return service.uploadTechCertCourses(map);
		}catch(Exception ex) {
			log.error(ex.getMessage(), ex);
			ParameterTool.writeErrorResponse(response);
		}

		return null;
	}

	@RequestMapping("/uploadTechCertByUserId.aspx")
	public ModelAndView uploadTechCertByUserId(HttpServletRequest request, HttpServletResponse response) {
		try{
			Map<String, Object> map = ParameterTool.getParameterRequest(request, true);
			map.put("response", response);
			map.put("request", request);
			return service.uploadTechCertByUserId(map);
		}catch(Exception ex) {
			log.error(ex.getMessage(), ex);
			ParameterTool.writeErrorResponse(response);
		}
		return null;
	}

}
